<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Person</title>
<script type="text/javascript" language="javascript">
	window.onload = function(){
		document.getElementById("form").onsubmit = function(){
			return checkForm();
		};
	};	
	function checkForm(){
		var form = document.getElementById("form");
		var iderrormsg = document.getElementById("iderrormsg");
		var name = form.name.value;
		var age = form.age.value;
		var birthday =  form.birthday.value;
		var regex = /^\S+$/;
		var regexdate = /^\d{4}-[0-1]?\d-[0-3]?\d$/;
		if(!regex.test(name)){
			iderrormsg.textContent="name?";
			return false;
		}
		if(!regex.test(age)){
			iderrormsg.textContent="age?";
			return false;
		}
		if(!regex.test(birthday)){
			iderrormsg.textContent="birthday?";
			return false;
		}
		if(!regexdate.test(birthday)){
			iderrormsg.textContent="not date?";
			return false;
		}
		return true;
	};
</script>
</head>
<body>

<jsp:include page="header.jsp" />
<br><s:property value="person.name"/>
<br><s:property value="person.age"/>
<br><s:property value="person.birthday" />
<form id="form" action="personAction" method="post">
<table>
<tr><td>name:</td><td><input id="name" type="text" name="person.name"/></td></tr>
<tr><td>age:</td><td><input id="age" type="text" name="person.age"/></td></tr>
<tr><td>birthday:</td><td><input id="birthday" type="text" name="person.birthday"/>格式必须为:1998-1-1</td></tr>
<tr><td><input type="reset" value="重置"></td><td><input type="submit" value="提交"></td></tr>
</table>
</form>
<label id="iderrormsg" style="color: red"></label>
</body>
</html>